import http from "./http";
import { WorksType, WorksList, DiaryType, DiaryList, User,Login,ProjectList } from "@/api/type";

// 作品类型相关
export const uploadWorksTypeImg = async (file: FormData) => {
    const { data } = await http.post(`/blog/v1/works-type-imgload`, file);
    return data;
};

export const addWorksTypeInfo = async (ruleForm: WorksType) => {
    const { data } = await http.post(`/blog/v1/add-works-type`, ruleForm)
    return data
}

export const getWorksTypeInfo = async (currentPage: number, pageSize: number) => {
    const { data } = await http.get(`/blog/v1/get-works-type`, { currentPage, pageSize })
    return data
}

export const updateWorksTypeInfo = async (ruleForm: WorksType) => {
    const { data } = await http.post(`/blog/v1/update-works-type`, ruleForm)
    return data
}

export const delWorksTypeInfo = async (id: number) => {
    const { data } = await http.post(`/blog/v1/del-works-type`, { id })
    return data
}
// 作品相关
export const getWorksTypeList = async () => {
    const { data } = await http.get(`/blog-works-type-list`, {});
    return data;
}

export const uploadWorksImg = async (file: FormData) => {
    const { data } = await http.post(`/blog/v1/works-imgload`, file);
    return data;
};

export const addWorksInfo = async (ruleForm: WorksList) => {
    const { data } = await http.post(`/blog/v1/add-works`, ruleForm)
    return data
}

export const getWorksInfo = async (currentPage: number, pageSize: number) => {
    const { data } = await http.get(`/blog/v1/get-works`, { currentPage, pageSize })
    return data
}

export const updateWorksInfo = async (ruleForm: WorksList) => {
    const { data } = await http.post(`/blog/v1/update-works`, ruleForm)
    return data
}

export const delWorksInfo = async (id: number) => {
    const { data } = await http.post(`/blog/v1/del-works`, { id })
    return data
}
// 日记类型相关
export const uploadDiaryTypeImg = async (file: FormData) => {
    const { data } = await http.post(`/blog/v1/diary-type-imgload`, file);
    return data;
};

export const addDiaryTypeInfo = async (ruleForm: DiaryType) => {
    const { data } = await http.post(`/blog/v1/add-diary-type`, ruleForm)
    return data
}

export const getDiaryTypeInfo = async (currentPage: number, pageSize: number) => {
    const { data } = await http.get(`/blog/v1/get-diary-type`, { currentPage, pageSize })
    return data
}

export const updateDiaryTypeInfo = async (ruleForm: DiaryType) => {
    const { data } = await http.post(`/blog/v1/update-diary-type`, ruleForm)
    return data
}

export const delDiaryTypeInfo = async (id: number) => {
    const { data } = await http.post(`/blog/v1/del-diary-type`, { id })
    return data
}

// 日记相关
export const getDiaryTypeList = async () => {
    const { data } = await http.get(`/blog-diary-type-list`, {});
    return data;
}

export const addDiaryInfo = async (ruleForm: DiaryList) => {
    const { data } = await http.post(`/blog/v1/add-diary`, ruleForm)
    return data
}

export const getDiaryInfo = async (currentPage: number, pageSize: number) => {
    const { data } = await http.get(`/blog/v1/get-diary`, { currentPage, pageSize })
    return data
}

export const updateDiaryInfo = async (ruleForm: DiaryList) => {
    const { data } = await http.post(`/blog/v1/update-diary`, ruleForm)
    return data
}

export const delDiaryInfo = async (id: number) => {
    const { data } = await http.post(`/blog/v1/del-diary`, { id })
    return data
}

// 个人信息相关
export const getUserInfo = async () => {
    const { data } = await http.get(`/blog/v1/get-user`, {})
    return data
}

export const uploadAvatarImg = async (file: FormData) => {
    const { data } = await http.post(`/blog/v1/user-avatar-imglode`, file);
    return data;
}

export const uploadHomeBgImg = async (file: FormData) => {
    const { data } = await http.post(`/blog/v1/home-bg-imglode`, file);
    return data;
}

export const uploadDiaryBgImg = async (file: FormData) => {
    const { data } = await http.post(`/blog/v1/diary-bg-imglode`, file);
    return data;
};

export const updateUserInfo = async (ruleForm: User) => {
    const { data } = await http.post(`/blog/v1/update-user`, ruleForm);
    return data;
}

// 后台登录
export const login = async (ruleForm:Login) => {
    const {data} = await http.post(`/blog/v1/login`,ruleForm);
    return data
}

export const resetLogin = async (email:string) => {
    const {data} = await http.post(`/blog/v1/reset-login`,{email});
    return data
}
// 项目相关
export const uploadProjectImg = async (file: FormData) => {
    const { data } = await http.post(`/blog/v1/project-imgload`, file);
    return data;
};
export const addProjectInfo = async (ruleForm: WorksList) => {
    const { data } = await http.post(`/blog/v1/add-project`, ruleForm)
    return data
}
export const getProjectInfo = async (currentPage: number, pageSize: number) => {
    const { data } = await http.get(`/blog/v1/get-project`, { currentPage, pageSize })
    return data
}
export const updateProjectInfo = async (ruleForm: ProjectList) => {
    const { data } = await http.post(`/blog/v1/update-project`, ruleForm)
    return data
}
export const delProjectInfo = async (id: number) => {
    const { data } = await http.post(`/blog/v1/del-project`, { id })
    return data
}